/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package vnc;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

/**
 * @author ahmed
 */
public class About extends MIDlet implements CommandListener {

    private boolean midletPaused = false;

    //<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0|
    private java.util.Hashtable __previousDisplayables = new java.util.Hashtable();
    private TextBox VNC;
    private List list;
    private TextBox GPL;
    private TextBox MUFIX;
    private TextBox Team;
    private TextBox Help;
    private Command backCommand;
    private Command Menu;
    private Command backCommand1;
    private Command backCommand2;
    private Command backCommand3;
    private Command ExitCommand;
    private Command backCommand4;
    private Command backCommand5;
    //</editor-fold>//GEN-END:|fields|0|

    /**
     * The About constructor.
     */
    public About() {
    }

    //<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0|
    /**
     * Switches a display to previous displayable of the current displayable.
     * The <code>display</code> instance is obtain from the <code>getDisplay</code> method.
     */
    private void switchToPreviousDisplayable() {
        Displayable __currentDisplayable = getDisplay().getCurrent();
        if (__currentDisplayable != null) {
            Displayable __nextDisplayable = (Displayable) __previousDisplayables.get(__currentDisplayable);
            if (__nextDisplayable != null) {
                switchDisplayable(null, __nextDisplayable);
            }
        }
    }
    //</editor-fold>//GEN-END:|methods|0|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">//GEN-BEGIN:|0-initialize|0|0-preInitialize
    /**
     * Initilizes the application.
     * It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method.
     */
    private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize
        // write pre-initialize user code here
//GEN-LINE:|0-initialize|1|0-postInitialize
        // write post-initialize user code here
    }//GEN-BEGIN:|0-initialize|2|
    //</editor-fold>//GEN-END:|0-initialize|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">//GEN-BEGIN:|3-startMIDlet|0|3-preAction
    /**
     * Performs an action assigned to the Mobile Device - MIDlet Started point.
     */
    public void startMIDlet() {//GEN-END:|3-startMIDlet|0|3-preAction
        // write pre-action user code here
        switchDisplayable(null, getVNC());//GEN-LINE:|3-startMIDlet|1|3-postAction
        // write post-action user code here
    }//GEN-BEGIN:|3-startMIDlet|2|
    //</editor-fold>//GEN-END:|3-startMIDlet|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">//GEN-BEGIN:|4-resumeMIDlet|0|4-preAction
    /**
     * Performs an action assigned to the Mobile Device - MIDlet Resumed point.
     */
    public void resumeMIDlet() {//GEN-END:|4-resumeMIDlet|0|4-preAction
        // write pre-action user code here
//GEN-LINE:|4-resumeMIDlet|1|4-postAction
        // write post-action user code here
    }//GEN-BEGIN:|4-resumeMIDlet|2|
    //</editor-fold>//GEN-END:|4-resumeMIDlet|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">//GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch
    /**
     * Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable.
     * @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately
     * @param nextDisplayable the Displayable to be set
     */
    public void switchDisplayable(Alert alert, Displayable nextDisplayable) {//GEN-END:|5-switchDisplayable|0|5-preSwitch
        // write pre-switch user code here
        Display display = getDisplay();//GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch
        Displayable __currentDisplayable = display.getCurrent();
        if (__currentDisplayable != null  &&  nextDisplayable != null) {
            __previousDisplayables.put(nextDisplayable, __currentDisplayable);
        }
        if (alert == null) {
            display.setCurrent(nextDisplayable);
        } else {
            display.setCurrent(alert, nextDisplayable);
        }//GEN-END:|5-switchDisplayable|1|5-postSwitch
        // write post-switch user code here
    }//GEN-BEGIN:|5-switchDisplayable|2|
    //</editor-fold>//GEN-END:|5-switchDisplayable|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">//GEN-BEGIN:|7-commandAction|0|7-preCommandAction
    /**
     * Called by a system to indicated that a command has been invoked on a particular displayable.
     * @param command the Command that was invoked
     * @param displayable the Displayable where the command was invoked
     */
    public void commandAction(Command command, Displayable displayable) {//GEN-END:|7-commandAction|0|7-preCommandAction
        // write pre-action user code here
        if (displayable == GPL) {//GEN-BEGIN:|7-commandAction|1|35-preAction
            if (command == backCommand1) {//GEN-END:|7-commandAction|1|35-preAction
                // write pre-action user code here
                switchDisplayable(null, getList());//GEN-LINE:|7-commandAction|2|35-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|3|60-preAction
        } else if (displayable == Help) {
            if (command == backCommand5) {//GEN-END:|7-commandAction|3|60-preAction
                // write pre-action user code here
                switchToPreviousDisplayable();//GEN-LINE:|7-commandAction|4|60-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|5|41-preAction
        } else if (displayable == MUFIX) {
            if (command == backCommand2) {//GEN-END:|7-commandAction|5|41-preAction
                // write pre-action user code here
                switchDisplayable(null, getList());//GEN-LINE:|7-commandAction|6|41-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|7|46-preAction
        } else if (displayable == Team) {
            if (command == backCommand3) {//GEN-END:|7-commandAction|7|46-preAction
                // write pre-action user code here
                switchDisplayable(null, getList());//GEN-LINE:|7-commandAction|8|46-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|9|30-preAction
        } else if (displayable == VNC) {
            if (command == Menu) {//GEN-END:|7-commandAction|9|30-preAction
                // write pre-action user code here
                switchDisplayable(null, getList());//GEN-LINE:|7-commandAction|10|30-postAction
                // write post-action user code here
            } else if (command == backCommand) {//GEN-LINE:|7-commandAction|11|16-preAction
                // write pre-action user code here
                switchDisplayable(null, getList());//GEN-LINE:|7-commandAction|12|16-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|13|51-preAction
        } else if (displayable == list) {
            if (command == ExitCommand) {//GEN-END:|7-commandAction|13|51-preAction
                // write pre-action user code here
                exitMIDlet();//GEN-LINE:|7-commandAction|14|51-postAction
                // write post-action user code here
            } else if (command == List.SELECT_COMMAND) {//GEN-LINE:|7-commandAction|15|23-preAction
                // write pre-action user code here
                listAction();//GEN-LINE:|7-commandAction|16|23-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|17|7-postCommandAction
        }//GEN-END:|7-commandAction|17|7-postCommandAction
        // write post-action user code here
    }//GEN-BEGIN:|7-commandAction|18|
    //</editor-fold>//GEN-END:|7-commandAction|18|


    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: VNC ">//GEN-BEGIN:|14-getter|0|14-preInit
    /**
     * Returns an initiliazed instance of VNC component.
     * @return the initialized component instance
     */
    public TextBox getVNC() {
        if (VNC == null) {//GEN-END:|14-getter|0|14-preInit
            // write pre-init user code here
            VNC = new TextBox("VNC Viewer", "Mobile VNC Viewer\n\nIs a VNC client built in\nJ2ME Technology.\n\nIt enables you to connect\nto your PC from any where using\nyour mobile phone.\n\nfor more info visit:\nwww.mufic.co.cc", 194, TextField.ANY | TextField.UNEDITABLE);//GEN-BEGIN:|14-getter|1|14-postInit
            VNC.addCommand(getBackCommand());
            VNC.addCommand(getMenu());
            VNC.setCommandListener(this);//GEN-END:|14-getter|1|14-postInit
            // write post-init user code here
        }//GEN-BEGIN:|14-getter|2|
        return VNC;
    }
    //</editor-fold>//GEN-END:|14-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: list ">//GEN-BEGIN:|22-getter|0|22-preInit
    /**
     * Returns an initiliazed instance of list component.
     * @return the initialized component instance
     */
    public List getList() {
        if (list == null) {//GEN-END:|22-getter|0|22-preInit
            // write pre-init user code here
            list = new List("list", Choice.IMPLICIT);//GEN-BEGIN:|22-getter|1|22-postInit
            list.append("Exit", null);
            list.append("Team", null);
            list.append("Licence", null);
            list.append("MUFIC", null);
            list.append("Help", null);
            list.addCommand(getExitCommand());
            list.setCommandListener(this);
            list.setSelectedFlags(new boolean[] { false, false, false, false, false });//GEN-END:|22-getter|1|22-postInit
            // write post-init user code here
        }//GEN-BEGIN:|22-getter|2|
        return list;
    }
    //</editor-fold>//GEN-END:|22-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: listAction ">//GEN-BEGIN:|22-action|0|22-preAction
    /**
     * Performs an action assigned to the selected list element in the list component.
     */
    public void listAction() {//GEN-END:|22-action|0|22-preAction
        // enter pre-action user code here
        String __selectedString = getList().getString(getList().getSelectedIndex());//GEN-BEGIN:|22-action|1|25-preAction
        if (__selectedString != null) {
            if (__selectedString.equals("Exit")) {//GEN-END:|22-action|1|25-preAction
                // write pre-action user code here
                exitMIDlet();//GEN-LINE:|22-action|2|25-postAction
                // write post-action user code here
            } else if (__selectedString.equals("Team")) {//GEN-LINE:|22-action|3|47-preAction
                // write pre-action user code here
                switchDisplayable(null, getTeam());//GEN-LINE:|22-action|4|47-postAction
                // write post-action user code here
            } else if (__selectedString.equals("Licence")) {//GEN-LINE:|22-action|5|26-preAction
                // write pre-action user code here
                switchDisplayable(null, getGPL());//GEN-LINE:|22-action|6|26-postAction
                // write post-action user code here
            } else if (__selectedString.equals("MUFIC")) {//GEN-LINE:|22-action|7|27-preAction
                // write pre-action user code here
                switchDisplayable(null, getMUFIX());//GEN-LINE:|22-action|8|27-postAction
                // write post-action user code here
            } else if (__selectedString.equals("Help")) {//GEN-LINE:|22-action|9|28-preAction
                // write pre-action user code here
                switchDisplayable(null, getHelp());//GEN-LINE:|22-action|10|28-postAction
                // write post-action user code here
            }//GEN-BEGIN:|22-action|11|22-postAction
        }//GEN-END:|22-action|11|22-postAction
        // enter post-action user code here
    }//GEN-BEGIN:|22-action|12|
    //</editor-fold>//GEN-END:|22-action|12|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand ">//GEN-BEGIN:|15-getter|0|15-preInit
    /**
     * Returns an initiliazed instance of backCommand component.
     * @return the initialized component instance
     */
    public Command getBackCommand() {
        if (backCommand == null) {//GEN-END:|15-getter|0|15-preInit
            // write pre-init user code here
            backCommand = new Command("Back", Command.BACK, 0);//GEN-LINE:|15-getter|1|15-postInit
            // write post-init user code here
        }//GEN-BEGIN:|15-getter|2|
        return backCommand;
    }
    //</editor-fold>//GEN-END:|15-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: Menu ">//GEN-BEGIN:|29-getter|0|29-preInit
    /**
     * Returns an initiliazed instance of Menu component.
     * @return the initialized component instance
     */
    public Command getMenu() {
        if (Menu == null) {//GEN-END:|29-getter|0|29-preInit
            // write pre-init user code here
            Menu = new Command("Ok", Command.OK, 0);//GEN-LINE:|29-getter|1|29-postInit
            // write post-init user code here
        }//GEN-BEGIN:|29-getter|2|
        return Menu;
    }
    //</editor-fold>//GEN-END:|29-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: GPL ">//GEN-BEGIN:|33-getter|0|33-preInit
    /**
     * Returns an initiliazed instance of GPL component.
     * @return the initialized component instance
     */
    public TextBox getGPL() {
        if (GPL == null) {//GEN-END:|33-getter|0|33-preInit
            // write pre-init user code here
            GPL = new TextBox("Licence", "This program is a free open\nsource software licenced under\nboth Waqf & GPL licences.\n\nWaqf licence is available here:\nwww.ojuba.org/wiki/doku.php/waqf/\n\nGPL licence is available here:\nwww.gnu.org/copyleft/gpl.html\n\npart of source code is based\non vidars holen program\n(vidance)(C).\nwww.vidarholen.net\n\nCopyright 2008-2009 Mufic.co.cc", 333, TextField.ANY);//GEN-BEGIN:|33-getter|1|33-postInit
            GPL.addCommand(getBackCommand1());
            GPL.setCommandListener(this);//GEN-END:|33-getter|1|33-postInit
            // write post-init user code here
        }//GEN-BEGIN:|33-getter|2|
        return GPL;
    }
    //</editor-fold>//GEN-END:|33-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand1 ">//GEN-BEGIN:|34-getter|0|34-preInit
    /**
     * Returns an initiliazed instance of backCommand1 component.
     * @return the initialized component instance
     */
    public Command getBackCommand1() {
        if (backCommand1 == null) {//GEN-END:|34-getter|0|34-preInit
            // write pre-init user code here
            backCommand1 = new Command("Back", Command.BACK, 0);//GEN-LINE:|34-getter|1|34-postInit
            // write post-init user code here
        }//GEN-BEGIN:|34-getter|2|
        return backCommand1;
    }
    //</editor-fold>//GEN-END:|34-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: MUFIX ">//GEN-BEGIN:|39-getter|0|39-preInit
    /**
     * Returns an initiliazed instance of MUFIX component.
     * @return the initialized component instance
     */
    public TextBox getMUFIX() {
        if (MUFIX == null) {//GEN-END:|39-getter|0|39-preInit
            // write pre-init user code here
            MUFIX = new TextBox("MUFIC", "\nMUFIC (Menufia University Faculty \nof Computers and Information).\n\nThis program was Developed at \nMUFIC. \nduring year 2008 in the Computer\nscience department as a project\nfor software engineering course.\n\nMUFIC is located in Shebin-Elkom\n Menufia Egypt.\n\nfor more info visit:\nwww.mufic.com\n\n", 363, TextField.ANY);//GEN-BEGIN:|39-getter|1|39-postInit
            MUFIX.addCommand(getBackCommand2());
            MUFIX.setCommandListener(this);//GEN-END:|39-getter|1|39-postInit
            // write post-init user code here
        }//GEN-BEGIN:|39-getter|2|
        return MUFIX;
    }
    //</editor-fold>//GEN-END:|39-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: Team ">//GEN-BEGIN:|44-getter|0|44-preInit
    /**
     * Returns an initiliazed instance of Team component.
     * @return the initialized component instance
     */
    public TextBox getTeam() {
        if (Team == null) {//GEN-END:|44-getter|0|44-preInit
            // write pre-init user code here
            Team = new TextBox("Team", "\nDeveloping Team:\n\n- Ahmed Salem.\nahmed_salem804@yahoo.com\n\n- Ahmed Daoud.\nahmed_daoud@link.net\n\n- Hany Mostafa.\njavaking_2015@yahoo.com", 136, TextField.ANY);//GEN-BEGIN:|44-getter|1|44-postInit
            Team.addCommand(getBackCommand3());
            Team.setCommandListener(this);//GEN-END:|44-getter|1|44-postInit
            // write post-init user code here
        }//GEN-BEGIN:|44-getter|2|
        return Team;
    }
    //</editor-fold>//GEN-END:|44-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand2 ">//GEN-BEGIN:|40-getter|0|40-preInit
    /**
     * Returns an initiliazed instance of backCommand2 component.
     * @return the initialized component instance
     */
    public Command getBackCommand2() {
        if (backCommand2 == null) {//GEN-END:|40-getter|0|40-preInit
            // write pre-init user code here
            backCommand2 = new Command("Back", Command.BACK, 0);//GEN-LINE:|40-getter|1|40-postInit
            // write post-init user code here
        }//GEN-BEGIN:|40-getter|2|
        return backCommand2;
    }
    //</editor-fold>//GEN-END:|40-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand3 ">//GEN-BEGIN:|45-getter|0|45-preInit
    /**
     * Returns an initiliazed instance of backCommand3 component.
     * @return the initialized component instance
     */
    public Command getBackCommand3() {
        if (backCommand3 == null) {//GEN-END:|45-getter|0|45-preInit
            // write pre-init user code here
            backCommand3 = new Command("Back", Command.BACK, 0);//GEN-LINE:|45-getter|1|45-postInit
            // write post-init user code here
        }//GEN-BEGIN:|45-getter|2|
        return backCommand3;
    }
    //</editor-fold>//GEN-END:|45-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: ExitCommand ">//GEN-BEGIN:|50-getter|0|50-preInit
    /**
     * Returns an initiliazed instance of ExitCommand component.
     * @return the initialized component instance
     */
    public Command getExitCommand() {
        if (ExitCommand == null) {//GEN-END:|50-getter|0|50-preInit
            // write pre-init user code here
            ExitCommand = new Command("Exit", Command.EXIT, 0);//GEN-LINE:|50-getter|1|50-postInit
            // write post-init user code here
        }//GEN-BEGIN:|50-getter|2|
        return ExitCommand;
    }
    //</editor-fold>//GEN-END:|50-getter|2|



    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand4 ">//GEN-BEGIN:|57-getter|0|57-preInit
    /**
     * Returns an initiliazed instance of backCommand4 component.
     * @return the initialized component instance
     */
    public Command getBackCommand4() {
        if (backCommand4 == null) {//GEN-END:|57-getter|0|57-preInit
            // write pre-init user code here
            backCommand4 = new Command("Back", Command.BACK, 0);//GEN-LINE:|57-getter|1|57-postInit
            // write post-init user code here
        }//GEN-BEGIN:|57-getter|2|
        return backCommand4;
    }
    //</editor-fold>//GEN-END:|57-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: Help ">//GEN-BEGIN:|58-getter|0|58-preInit
    /**
     * Returns an initiliazed instance of Help component.
     * @return the initialized component instance
     */
    public TextBox getHelp() {
        if (Help == null) {//GEN-END:|58-getter|0|58-preInit
            // write pre-init user code here
            Help = new TextBox("Help", "Mobile VNC Viewer is easy. \n\njust enter your host IP:Port \nnumber and your password \nthen click connect.\n\nwhen connection established\nyou will receive a screen telling\nyou to press fire to start.\n\nUse arrow keys to scroll screen \nUse 2,4,6,8 to simulate arrow keys.\nother keys:\n1 --> TAB\n3 --> BACK SPACE\n5 -- > ENTER\n7 --> WIN (start menu)\n9 --> MENU\n0 --> SPACE\n# --> ALT-TAB\n\nYou can use input menu\nfor special commands\nand for inputting text.", 446, TextField.ANY | TextField.UNEDITABLE);//GEN-BEGIN:|58-getter|1|58-postInit
            Help.addCommand(getBackCommand5());
            Help.setCommandListener(this);
            Help.setInitialInputMode("UCB_BASIC_LATIN");//GEN-END:|58-getter|1|58-postInit
            // write post-init user code here
        }//GEN-BEGIN:|58-getter|2|
        return Help;
    }
    //</editor-fold>//GEN-END:|58-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand5 ">//GEN-BEGIN:|59-getter|0|59-preInit
    /**
     * Returns an initiliazed instance of backCommand5 component.
     * @return the initialized component instance
     */
    public Command getBackCommand5() {
        if (backCommand5 == null) {//GEN-END:|59-getter|0|59-preInit
            // write pre-init user code here
            backCommand5 = new Command("Back", Command.BACK, 0);//GEN-LINE:|59-getter|1|59-postInit
            // write post-init user code here
        }//GEN-BEGIN:|59-getter|2|
        return backCommand5;
    }
    //</editor-fold>//GEN-END:|59-getter|2|

    /**
     * Returns a display instance.
     * @return the display instance.
     */
    public Display getDisplay () {
        return Display.getDisplay(this);
    }

    /**
     * Exits MIDlet.
     */
    public void exitMIDlet() {
        switchDisplayable (null, null);
        destroyApp(true);
        notifyDestroyed();
    }

    /**
     * Called when MIDlet is started.
     * Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
     */
    public void startApp() {
        if (midletPaused) {
            resumeMIDlet ();
        } else {
            initialize ();
            startMIDlet ();
        }
        midletPaused = false;
    }

    /**
     * Called when MIDlet is paused.
     */
    public void pauseApp() {
        midletPaused = true;
    }

    /**
     * Called to signal the MIDlet to terminate.
     * @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
     */
    public void destroyApp(boolean unconditional) {
    }

}
